package se.webbzon.boltzmann.game.object.platform;

import se.webbzon.boltzmann.configuration.Graphics;
import se.webbzon.boltzmann.effect.Shadow2DEffect;
import se.webbzon.boltzmann.resource.Resources;
import se.webbzon.oschi01.resourceset.ResourceSet;
import se.webbzon.oschi01.textureset.Texture3D;
import se.webbzon.oschi01.worldeditor.DeflatableWorldObject;
import se.webbzon.oschi01.worldeditor.WorldObjectDeflation;

public class PlatformShadow extends Shadow2DEffect implements DeflatableWorldObject {

	// The name of the deflatable world object
	public static final String worldObjectName = "platformShadow";
	
	// The shape of the shadow
	private final PlatformShadowShape shape;
	
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a platform shadow. **/
	public PlatformShadow(Platform platform, PlatformShadowShape shape) {
		super(platform,getTextureSet(shape));
		if (Graphics.instance().hasShadows())
			platform.setShadow(this);
		else
			setVisible(false);
		this.shape = shape;
	}

	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the platform associated with this platform shadow. **/
	public Platform getPlatform() {
		return (Platform) getParent();
	}
	
	/** Returns the shape of the platform shadow. **/
	public PlatformShadowShape getShape() {
		return shape;
	}

	@Override public String getName() {
		return worldObjectName;
	}

	@Override public WorldObjectDeflation getDeflation() {
		return new PlatformShadowDeflation(0,this,(Platform) getParent());
	}
	
	/*============================================================
	Private Methods
	============================================================*/
	
	private static final ResourceSet<Texture3D> getTextureSet(PlatformShadowShape shape) {
		if (shape == PlatformShadowShape.CIRCLE)
			return Resources.getTextureSet("effect_shadow_circle");
		else
			return null;
	}

}
